﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Data;


namespace hotel
{
    public class comandos
    {

        public void login(string user, string pass)
        {

        }

        public void buscar() 
        {
           
        }
        public void add_reserva(int _idcliente,
                                int _idhab,
                                string _fecha_ini,
                                string _fecha_fin)

        {
            SqlConnection cs = new SqlConnection();
            cs.ConnectionString = "Data Source=localhost;Initial Catalog=hotel;Integrated Security=True";
            SqlCommand add_res = new SqlCommand("addreserva", cs);
            add_res.CommandType = CommandType.StoredProcedure;
            add_res.Parameters.AddWithValue("@idcliente", _idcliente);
            add_res.Parameters.AddWithValue("@idhabit", _idhab);
            add_res.Parameters.AddWithValue("@fechaini", _fecha_ini);
            add_res.Parameters.AddWithValue("@fechafin", _fecha_fin);

            try
            {
            cs.Open();
            add_res.ExecuteNonQuery();

            }
            catch (Exception ex)
            {
                throw new Exception("error " + ex.Message);
            }
            finally
            {
                cs.Close();
            }
        }

        public void add_habit(int _idhab,
                              string _tipo_hab,
                              int _precio) 
        {
            SqlConnection cs = new SqlConnection();
            cs.ConnectionString = "Data Source=localhost;Initial Catalog=hotel;Integrated Security=True";
            SqlCommand addhab = new SqlCommand("add_habit", cs);
            addhab.CommandType = CommandType.StoredProcedure;
            addhab.Parameters.AddWithValue("@idhabit", _idhab);
            addhab.Parameters.AddWithValue("@tipohab", _tipo_hab);
            addhab.Parameters.AddWithValue("@precio", _precio);
           

            try
            {
                cs.Open();
                addhab.ExecuteNonQuery();

            }
            catch (Exception ex)
            {
                throw new Exception("Exeption adding account. " + ex.Message);
            }
            finally
            {
                cs.Close();
            }
        }

        public void edit_habint (int _idhab,
                              string _tipo_hab,
                              int _precio)

                                  {
            SqlConnection cs = new SqlConnection();
            cs.ConnectionString = "Data Source=localhost;Initial Catalog=hotel;Integrated Security=True";
            SqlCommand edit = new SqlCommand("edit_hab", cs);
            edit.CommandType = CommandType.StoredProcedure;
            edit.Parameters.AddWithValue("@idhab", _idhab);
            edit.Parameters.AddWithValue("@tipohab", _tipo_hab);
            edit.Parameters.AddWithValue("@precio", _precio);
           

            try
            {
                cs.Open();
                edit.ExecuteNonQuery();

            }
            catch (Exception ex)
            {
                throw new Exception("Exeption adding account. " + ex.Message);
            }
            finally
            {
                cs.Close();
            }
        }

        public void borrar_habit(int _idhab)
        {
            SqlConnection cs = new SqlConnection();
            cs.ConnectionString = "Data Source=localhost;Initial Catalog=hotel;Integrated Security=True";
            SqlCommand del = new SqlCommand("borrar_habit", cs);
            del.CommandType = CommandType.StoredProcedure;
            del.Parameters.AddWithValue("@idhab", _idhab);
           
            try
            {
                cs.Open();
                del.ExecuteNonQuery();

            }
            catch (Exception ex)
            {
                throw new Exception("Exeption adding account. " + ex.Message);
            }
            finally
            {
                cs.Close();
            }
        }
        public void promociones(int _desc,
                                string _tipo_hab,
                                string _tipo_cli,
                                string _fecha_ini,
                                string _fecha_fin)

        {
            SqlConnection cs = new SqlConnection();
            cs.ConnectionString = "Data Source=localhost;Initial Catalog=hotel;Integrated Security=True";
            SqlCommand prom = new SqlCommand("addpromo", cs);
            prom.CommandType = CommandType.StoredProcedure;
            prom.Parameters.AddWithValue("@desc",_desc);
            prom.Parameters.AddWithValue("@tipo_hab",_tipo_hab);
            prom.Parameters.AddWithValue("@tipo_cli",_tipo_cli);
            prom.Parameters.AddWithValue("@fechaini",_fecha_ini);
            prom.Parameters.AddWithValue("@fechafin",_fecha_fin);

            try
	{
		cs.Open();
		prom.ExecuteNonQuery();
        
	}
	catch (Exception ex)
	{
		throw new Exception("Exeption adding account. " + ex.Message);
	}
	finally
	{
		cs.Close();
	}
}







        }






    }

